import { StatusBar, StatusBarStyle, NativeModules } from 'react-native';
import { isIOS, NOTCH_WIDTH } from '../../constant';

const statusBarHeight = 20;

const getStatusBarHeight = (): number => {
  if (NOTCH_WIDTH > 0) {
    return NOTCH_WIDTH;
  }
  if (isIOS) {
    return statusBarHeight;
  }
  return StatusBar.currentHeight || 0;
};

const setBarStyle = (style: StatusBarStyle, animated?: boolean): void => {
  if (!isIOS) {
    StatusBar.setBarStyle(style, !!animated);
  } else {
    NativeModules.RNStatusBarManager.setBarStyle(style, !!animated);
  }
};

export default {
  getStatusBarHeight,
  setBarStyle
};
